package org.erepublik.company.log;

import java.io.FileOutputStream;
import java.util.Date;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.HTMLLayout;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.WriterAppender;
import org.erepublik.company.Configuration;

/**
 * Loguje wejsnia na strony
 *
 * @author Kacper Gorski 'Railman' railman85@gmail.com
 */
public class SitesLogger{

    private String path = Configuration.databasePath+"/log/"+new Date().getTime()+"sites.html";
    private Logger logger;
    public SitesLogger() {
        
        BasicConfigurator.configure();
        logger = Logger.getLogger(SitesLogger.class);
        HTMLLayout layout = new HTMLLayout();

        WriterAppender appender = null;
        try {
           FileOutputStream output = new FileOutputStream(path);
           appender = new WriterAppender(layout,output);
        } catch(Exception e) {}

        logger.addAppender(appender);
        logger.setLevel((Level) Level.DEBUG);

    }
    

    public void log(String source, String parameters) {
        logger.info( new Date()+ " entered "+source+" width parameters: "+parameters);
    }
    
    
    public static void main(String[] args) {
       
    }
    
  
    
}
